home *** CD-ROM | disk | FTP | other *** search
- Path: god.bel.alcatel.be!btmpj7!ian
- From: ian@rsd.bel.alcatel.be (Ian Ward)
- Newsgroups: comp.lang.c
- Subject: Re: Tough FACTORIAL math problem...
- Date: 16 Feb 1996 15:34:19 GMT
- Organization: Alcatel Bell Telephone
- Distribution: world
- Message-ID: <4g285r$gre@btmpjg.god.bel.alcatel.be>
- References: <4g0giv$94s@sun132.spd.dsccc.com>
- Reply-To: ian@rsd.bel.alcatel.be
- NNTP-Posting-Host: btmpj7.rsd.bel.alcatel.be
-
- Kevin Cline
- > With a bit more thought a log n solution is possible.
-
- int last_digit (num)
- int num;
- { static int tens [4] = {8,4,2,6};
- static int singles [10] = {1, 1, 2, 6, 4, 2, 2, 4, 2, 8};
- int single = singles [num % 10];
- if (num > 9) single *= tens [(num/10-1) % 4];
- return single % 10;
- }
-
- I make the 427! last digit 6.
-
- ---
- Ian Ward's opinions only : ian@rsd.bel.alcatel.be
-
-